<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.8"/>
<title>embedme: libemb/inc/Gpio.h 源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="logo.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">embedme
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.8.8 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>首页</span></a></li>
      <li><a href="annotated.html"><span>类</span></a></li>
      <li class="current"><a href="files.html"><span>文件</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>文件列表</span></a></li>
      <li><a href="globals.html"><span>文件成员</span></a></li>
    </ul>
  </div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_574d9269cd334a9d02d8928365303d98.html">libemb</a></li><li class="navelem"><a class="el" href="dir_207aad82934689048a9003fb51f06f7f.html">inc</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">Gpio.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_gpio_8h.html">浏览该文件的文档.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">/******************************************************************************</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment"> * This file is part of libemb.</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment"> * libemb is free software: you can redistribute it and/or modify</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment"> * it under the terms of the GNU General Public License as published by</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment"> * the Free Software Foundation, either version 3 of the License, or</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="comment"> * (at your option) any later version.</span></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="comment"> * libemb is distributed in the hope that it will be useful,</span></div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="comment"> * GNU General Public License for more details.</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="comment"> * You should have received a copy of the GNU General Public License</span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="comment"> * along with libemb.  If not, see &lt;http://www.gnu.org/licenses/&gt;.</span></div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="comment"> * Project: Embedme</span></div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;<span class="comment"> * Author : FergusZeng</span></div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="comment"> * Email  : cblock@126.com</span></div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;<span class="comment"> * git    : https://git.oschina.net/cblock/embedme</span></div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="comment"> * Copyright 2014 @ ShenZhen ,China</span></div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;<span class="comment">*******************************************************************************/</span></div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="preprocessor">#ifndef __GPIO_H__</span></div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;<span class="preprocessor">#define __GPIO_H__</span></div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;</div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_base_type_8h.html">BaseType.h</a>&quot;</span></div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;<span class="preprocessor">#include &lt;map&gt;</span></div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;<span class="preprocessor">#include &lt;iostream&gt;</span></div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;</div>
<div class="line"><a name="l00036"></a><span class="lineno"><a class="line" href="class_g_p_i_o.html">   36</a></span>&#160;<span class="keyword">class </span><a class="code" href="class_g_p_i_o.html">GPIO</a>{</div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;    <span class="keyword">static</span> <span class="keyword">const</span> sint32 LOW  = 0;</div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;    <span class="keyword">static</span> <span class="keyword">const</span> sint32 HIGH = 1;</div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;    <span class="keyword">static</span> <span class="keyword">const</span> sint32 IN   = 0;</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;    <span class="keyword">static</span> <span class="keyword">const</span> sint32 OUT  = 1;</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;};</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;</div>
<div class="line"><a name="l00048"></a><span class="lineno"><a class="line" href="struct_gpio_info___s.html">   48</a></span>&#160;<span class="keyword">typedef</span> <span class="keyword">struct</span>{</div>
<div class="line"><a name="l00049"></a><span class="lineno"><a class="line" href="struct_gpio_info___s.html#ad40150800f49d3e77ce36da3f45d1273">   49</a></span>&#160;    sint32 <a class="code" href="struct_gpio_info___s.html#ad40150800f49d3e77ce36da3f45d1273">m_label</a>;         </div>
<div class="line"><a name="l00050"></a><span class="lineno"><a class="line" href="struct_gpio_info___s.html#abd2e8c90c9941d4143e0447227b29bd5">   50</a></span>&#160;    std::string <a class="code" href="struct_gpio_info___s.html#abd2e8c90c9941d4143e0447227b29bd5">m_group</a>;    </div>
<div class="line"><a name="l00051"></a><span class="lineno"><a class="line" href="struct_gpio_info___s.html#a79507150655aab0dcb7b79b27a4ed20d">   51</a></span>&#160;    sint32 <a class="code" href="struct_gpio_info___s.html#a79507150655aab0dcb7b79b27a4ed20d">m_pin</a>;           </div>
<div class="line"><a name="l00052"></a><span class="lineno"><a class="line" href="struct_gpio_info___s.html#a0ef99112e1613f6efbd5a89dd05a2736">   52</a></span>&#160;    sint32 <a class="code" href="struct_gpio_info___s.html#a0ef99112e1613f6efbd5a89dd05a2736">m_dir</a>;           </div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;}<a class="code" href="struct_gpio_info___s.html">GpioInfo_S</a>;</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;<span class="keyword">class </span><a class="code" href="class_gpio_factory.html">GpioFactory</a>;</div>
<div class="line"><a name="l00062"></a><span class="lineno"><a class="line" href="class_gpio_imp.html">   62</a></span>&#160;<span class="keyword">class </span><a class="code" href="class_gpio_imp.html">GpioImp</a>{</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;    ~<a class="code" href="class_gpio_imp.html">GpioImp</a>();</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;    sint32 <a class="code" href="class_gpio_imp.html#aefb4c2fdea4a30fd7f136a6695c455eb">config</a>(sint32 dir, sint32 value=GPIO::LOW);</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;    sint32 <a class="code" href="class_gpio_imp.html#a4c876cc941983087c6ac9429f5de0c5d">setPinValue</a>(sint32 value);</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;    sint32 <a class="code" href="class_gpio_imp.html#a54a258bb37a30093e9630483d78595ee">getPinValue</a>();</div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;<span class="keyword">private</span>:</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;    <a class="code" href="class_gpio_imp.html">GpioImp</a>(sint32 fd);</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;    <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="class_gpio_factory.html">GpioFactory</a>;</div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;<span class="keyword">private</span>:</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;    sint32 m_fd;</div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;    std::string m_gpioDir;</div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;    std::string m_gpioExportFile;</div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;    std::string m_gpioDirectionFile;</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;    std::string m_gpioValueFile;</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;};</div>
<div class="line"><a name="l00084"></a><span class="lineno"><a class="line" href="class_gpio_factory.html">   84</a></span>&#160;<span class="keyword">class </span><a class="code" href="class_gpio_factory.html">GpioFactory</a>{</div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00092"></a><span class="lineno"><a class="line" href="class_gpio_factory.html#a8c4b5da16683b5267c5d70084e747c76">   92</a></span>&#160;    <span class="keyword">static</span> <a class="code" href="class_gpio_factory.html">GpioFactory</a>* <a class="code" href="class_gpio_factory.html#a8c4b5da16683b5267c5d70084e747c76">getInstance</a>()</div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;    {</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;        <span class="keyword">static</span> <a class="code" href="class_gpio_factory.html">GpioFactory</a> instance;</div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;        <span class="keywordflow">return</span> &amp;instance;</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;    }</div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;    ~<a class="code" href="class_gpio_factory.html">GpioFactory</a>(){};</div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;    <a class="code" href="class_gpio_imp.html">GpioImp</a>* <a class="code" href="class_gpio_factory.html#a36d0d31672bf17f188e1cd4ca3701d79">getGpioImp</a>(std::string group, sint32 pin);</div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;<span class="keyword">private</span>:</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;    <a class="code" href="class_gpio_factory.html">GpioFactory</a>(){};</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;    <span class="keyword">typedef</span> std::map&lt;int, GpioImp*&gt; GpioImpMap;</div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;    GpioImpMap m_gpioImpTable;</div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;};</div>
<div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;</div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="ttc" id="class_g_p_i_o_html"><div class="ttname"><a href="class_g_p_i_o.html">GPIO</a></div><div class="ttdoc">GPIO状态常量 </div><div class="ttdef"><b>Definition:</b> Gpio.h:36</div></div>
<div class="ttc" id="class_gpio_factory_html_a36d0d31672bf17f188e1cd4ca3701d79"><div class="ttname"><a href="class_gpio_factory.html#a36d0d31672bf17f188e1cd4ca3701d79">GpioFactory::getGpioImp</a></div><div class="ttdeci">GpioImp * getGpioImp(std::string group, sint32 pin)</div><div class="ttdoc">GPIO工厂获取GPIO实例 </div><div class="ttdef"><b>Definition:</b> Gpio.cpp:288</div></div>
<div class="ttc" id="class_gpio_factory_html"><div class="ttname"><a href="class_gpio_factory.html">GpioFactory</a></div><div class="ttdoc">Gpio工厂类,负责管理创建和管理Gpio. </div><div class="ttdef"><b>Definition:</b> Gpio.h:84</div></div>
<div class="ttc" id="struct_gpio_info___s_html_ad40150800f49d3e77ce36da3f45d1273"><div class="ttname"><a href="struct_gpio_info___s.html#ad40150800f49d3e77ce36da3f45d1273">GpioInfo_S::m_label</a></div><div class="ttdeci">sint32 m_label</div><div class="ttdef"><b>Definition:</b> Gpio.h:49</div></div>
<div class="ttc" id="class_gpio_imp_html_a4c876cc941983087c6ac9429f5de0c5d"><div class="ttname"><a href="class_gpio_imp.html#a4c876cc941983087c6ac9429f5de0c5d">GpioImp::setPinValue</a></div><div class="ttdeci">sint32 setPinValue(sint32 value)</div><div class="ttdoc">设置GPIO Pin输出电平 </div><div class="ttdef"><b>Definition:</b> Gpio.cpp:209</div></div>
<div class="ttc" id="class_gpio_factory_html_a8c4b5da16683b5267c5d70084e747c76"><div class="ttname"><a href="class_gpio_factory.html#a8c4b5da16683b5267c5d70084e747c76">GpioFactory::getInstance</a></div><div class="ttdeci">static GpioFactory * getInstance()</div><div class="ttdoc">获取GpioFactory单例 </div><div class="ttdef"><b>Definition:</b> Gpio.h:92</div></div>
<div class="ttc" id="class_gpio_imp_html_a54a258bb37a30093e9630483d78595ee"><div class="ttname"><a href="class_gpio_imp.html#a54a258bb37a30093e9630483d78595ee">GpioImp::getPinValue</a></div><div class="ttdeci">sint32 getPinValue()</div><div class="ttdoc">读取GPIO Pin输入电平 </div><div class="ttdef"><b>Definition:</b> Gpio.cpp:247</div></div>
<div class="ttc" id="class_gpio_imp_html_aefb4c2fdea4a30fd7f136a6695c455eb"><div class="ttname"><a href="class_gpio_imp.html#aefb4c2fdea4a30fd7f136a6695c455eb">GpioImp::config</a></div><div class="ttdeci">sint32 config(sint32 dir, sint32 value=GPIO::LOW)</div><div class="ttdoc">配置GPIO </div><div class="ttdef"><b>Definition:</b> Gpio.cpp:120</div></div>
<div class="ttc" id="struct_gpio_info___s_html_a79507150655aab0dcb7b79b27a4ed20d"><div class="ttname"><a href="struct_gpio_info___s.html#a79507150655aab0dcb7b79b27a4ed20d">GpioInfo_S::m_pin</a></div><div class="ttdeci">sint32 m_pin</div><div class="ttdef"><b>Definition:</b> Gpio.h:51</div></div>
<div class="ttc" id="struct_gpio_info___s_html"><div class="ttname"><a href="struct_gpio_info___s.html">GpioInfo_S</a></div><div class="ttdoc">GPIO信息结构体 </div><div class="ttdef"><b>Definition:</b> Gpio.h:48</div></div>
<div class="ttc" id="struct_gpio_info___s_html_a0ef99112e1613f6efbd5a89dd05a2736"><div class="ttname"><a href="struct_gpio_info___s.html#a0ef99112e1613f6efbd5a89dd05a2736">GpioInfo_S::m_dir</a></div><div class="ttdeci">sint32 m_dir</div><div class="ttdef"><b>Definition:</b> Gpio.h:52</div></div>
<div class="ttc" id="struct_gpio_info___s_html_abd2e8c90c9941d4143e0447227b29bd5"><div class="ttname"><a href="struct_gpio_info___s.html#abd2e8c90c9941d4143e0447227b29bd5">GpioInfo_S::m_group</a></div><div class="ttdeci">std::string m_group</div><div class="ttdef"><b>Definition:</b> Gpio.h:50</div></div>
<div class="ttc" id="class_gpio_imp_html"><div class="ttname"><a href="class_gpio_imp.html">GpioImp</a></div><div class="ttdoc">Gpio实例类 </div><div class="ttdef"><b>Definition:</b> Gpio.h:62</div></div>
<div class="ttc" id="_base_type_8h_html"><div class="ttname"><a href="_base_type_8h.html">BaseType.h</a></div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
生成于 2016年 七月 7日 星期四 19:49:37 , 为 embedme使用  &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.8
</small></address>
</body>
</html>
